package com.ruoyi.web.controller.fenxiang;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.common.core.domain.model.LoginUser;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.utils.ServletUtils;
import com.ruoyi.framework.web.service.TokenService;
import com.ruoyi.system.domain.customer.CustomerInfo;
import com.ruoyi.system.domain.zhuangxiumain.orderformMain.OrderMaster;
import com.ruoyi.system.mapper.SysUserMapper;
import com.ruoyi.system.service.ISysUserService;
import com.ruoyi.system.service.zhaungxiuservice.shopService.OrderMasterService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/fenzhan/order")
public class FenZhanOrderController extends BaseController {

    @Autowired
    private SysUserMapper sysUserMapper;

    @Autowired
    private OrderMasterService orderMasterService;

    @Autowired(required = false)
    private TokenService tokenService;

    @GetMapping("/list")
    public TableDataInfo list(OrderMaster orderMaster)
    {
        startPage();
        LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
        Long userId = loginUser.getUser().getUserId();
//        Long userId = (long)61;
        SysUser aById = sysUserMapper.findAById(userId);

        orderMaster.setAddress(aById.getDept().getDeptName());
        List<OrderMaster> fenZhan = orderMasterService.findFenZhan(orderMaster);
        return getDataTable(fenZhan);
    }





}
